#include "tab_defense.h"
#include "client_print.h"

CTabDefense::CTabDefense(QWidget* pParent) :
	QWidget(pParent),
	mLayout(this),
	mIOSplitter(Qt::Vertical),
	mDefenseSpinner(new QScrollBar()),
	mDefenseLabel(new QLabel())
{
	setupUiElements();
	setupActions();
}

CTabDefense::~CTabDefense()
{
}

void CTabDefense::setupUiElements()
{
	mDefenseSpinner->setMaximum(0);
	mDefenseSpinner->setMaximum(1000);
	mDefenseSpinner->setSingleStep(1);
	//mDefenseSpinner->setInvertedControls(true);
	//mDefenseSpinner->setInvertedAppearance(true);
	mDefenseLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
	mDefenseLabel->setText(QString::number(mDefenseSpinner->sliderPosition()));

	mIOSplitter.addWidget(mDefenseSpinner);
	mIOSplitter.addWidget(mDefenseLabel);
	
	mLayout.addWidget(&mIOSplitter);
}

void CTabDefense::setupActions()
{
	connect(mDefenseSpinner, SIGNAL(valueChanged(int)),
			this, SLOT(defenseValueChanged(int)));
}

void CTabDefense::startRequested()
{
	
}

void CTabDefense::defenseValueChanged(int pValue)
{
	mDefenseLabel->setText(QString::number(pValue));
	emit sendDefenseValue(static_cast<quint32>(pValue));
}
